#include <iostream>
#include <string>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>

using namespace std;

int gval = 100;

int main()
{
    pid_t id = vfork();    
    if(id == 0)
    {
        gval = 200;
        printf("child gval: %d\n", gval);
        exit(0);
    }

    printf("parent gval: %d\n", gval);
    waitpid(id, nullptr, 0);


    return 0;
}

struct MultipartFormData {
    std::string name;
    std::string content;
    std::string filename;
    std::string content_type;
};
       using MultipartFormDataItems = std::vector<MultipartFormData>;

struct Response {
    std::string version;
    int status = -1;
    std::string reason;
    Headers headers;
    std::string body;
    std::string location; // Redirect location
    void set_header(const char *key, const char *val);
    void set_content(const std::string &s, const char *content_type);
};


class Server {
    using Handler = std::function<void(const Request &, Response &)>;
    using Handlers = std::vector<std::pair<std::regex, Handler>>;
    std::function<TaskQueue *(void)> new_task_queue;
    Server &Get(const std::string &pattern, Handler handler);
      Server &Post(const std::string &pattern, Handler handler);
    Server &Put(const std::string &pattern, Handler handler);
      Server &Patch(const std::string &pattern, Handler handler);
      Server &Delete(const std::string &pattern, Handler handler);
      Server &Options(const std::string &pattern, Handler handler);
    bool listen(const char *host, int port, int socket_flags = 0);
};

class Client {
    Client(const std::string &host, int port);
    Result Get(const char *path, const Headers &headers);
    Result Post(const char *path, const char *body, size_t content_length,
    const char *content_type);
    Result Post(const char *path, const MultipartFormDataItems &items);
}